from fastapi import APIRouter, Query
from core.schemas.pagination import PaginatedResponse
from src.modules.knowbase.services.Impl.textvector_service import TextVectorService
from core.schemas.response import success

router = APIRouter(prefix="/tv", tags = ["tv"])


@router.get("/list",response_model = PaginatedResponse)
async def get_tv_list(
        user_id: str = Query(None, description="用户id"),
        file_id: str = Query(None, description="文件id"),
        kb_id: str = Query(None, description="知识库id"),
        page:int = Query(1, description="页码",ge=1),
        page_size:int = Query(10, description="每页条数",le=100)
        ) :
    result = await TextVectorService.get_textvector_list(
        user_id, file_id, kb_id, page, page_size
    )
    return success(data=result)


@router.delete("/delete")
async def delete_vector(vector_id:str):
    result = await TextVectorService.delete_vector(vector_id)
    return success(data=result)


@router.put("/update")
async def update_text_vector_by_id(vector_id:str,text_content:str):
    result = await TextVectorService.update_text_vector_by_id(vector_id, text_content)
    return success(data=result)

